<template>
    <div>
        <button @click="skipRouter">点击跳转</button>
    </div>
</template>
<script setup>
import { useRouter, onBeforeRouteLeave } from 'vue-router';
const router = useRouter();

onBeforeRouteLeave((to, from, next) => {
    console.log('离开路由');
    next();
});
// 命名式路由与编程式导航
const skipRouter = () => {
    router.push({ name: 'vueUse', params: { id: 1 } });
};
</script>
